﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using AspNetCs.Common;
using AspNetCs.Bll;
using AspNetCs.Model;

public partial class Master_SendMessage :Admin_BasePage
{
    private MessageBLL messageBLL = Message_BLL.CreateNew;
    protected int ReciverId = 0;
    protected string UserName = "";

    protected void Page_Load(object sender, EventArgs e)
    {
        IsExit();
        if (!IsPostBack)
        {
            ReciverId = StringHelper.isNumber_int(Request["UserId"]);
            UserName = Request["UserName"];
            ViewState["ReciverId"] = ReciverId.ToString();
        }
        else
        {
            if (ViewState["ReciverId"]!=null)
            {
                ReciverId = StringHelper.isNumber_int(ViewState["ReciverId"].ToString());
            }
            if (ViewState["UserName"]!=null)
            {
                UserName = ViewState["UserName"].ToString();
            }
        }
    }
    protected void btnSend_Click(object sender, EventArgs e)
    {
        MessageModel model = new MessageModel();

        int UserId = AdminInfo.Id;
        string title = txtTitle.Text;
        string content = WebEditor1.Text;
        model.Content = content;
        model.Title = txtTitle.Text;
        model.IsDel = 0;
        model.ReciverId = ReciverId;
        model.ReciverIsMaster = 0;
        model.SenderId = UserId;
        model.SenderIsMaster = 1;
        model.IsAll = 0;
        int i = messageBLL.Add(model);
        Page.RegisterStartupScript("showClose", "<script>alert('发送成功!');window.parent.g_close_pop();</script>");

    }
}
